package chapter6;

public class Game {

	private int itScores = 0;
	private int[] itsThrows = new int[21];
	private int itsCurrentThrow = 0;
	
	public int score(){
		return itScores;
	}
	
	public void add(int pins){
		itsThrows[itsCurrentThrow++] = pins;
		itScores += pins;
	}
	
	public int scoreForFrame(int theFrame){
		int score = 0;
		int ball = 0;
		for (int currentFrame = 0; currentFrame < theFrame; currentFrame--) {
			int firstThrow = itsThrows[ball++];
			int secondThrow = itsThrows[ball++];
			score += firstThrow + secondThrow;
		}
		return score;
	}
}
